package com.charging.controller;

import com.charging.entity.ChargingPile;
import com.charging.service.ChargingPileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;

@Controller
@RequestMapping("/api/map")
public class PileMapController {
    private final ChargingPileService chargingPileService;

    public PileMapController(ChargingPileService chargingPileService) {
        this.chargingPileService = chargingPileService;
    }

    /**
     * 获取地图范围内的充电桩
     */
    @GetMapping("/piles-in-range")
    public List<ChargingPile> getPilesInRange(
            @RequestParam Double minLat,
            @RequestParam Double maxLat,
            @RequestParam Double minLng,
            @RequestParam Double maxLng) {
        return chargingPileService.getPilesInMapRange(minLat, maxLat, minLng, maxLng);
    }

    /**
     * 获取所有充电桩的位置信息
     */
    @GetMapping("/all-pile-locations")
    public List<ChargingPile> getAllPileLocations() {
        return chargingPileService.getAllPileLocations();
    }
}